<template>
  <div class="dashboard-container">
    <div class="dashboard-text">name: {{ username }}</div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
// import {hello} from '@/api/user'
import { Base64 } from 'js-base64'
export default {
  data() {
    return {
      username: "aaa"
    }
  },
  name: 'Dashboard',
  computed: {
    ...mapGetters([
      ...name
    ])
  },
  created(){
      // hello().then(res=>{
      //     // console.log(res);  
      // })
      this.getInfo()
  },
  methods: {
    //解析token，拿到图片和名称
    getInfo(){
      let token = localStorage.getItem('token')
      let paylod = token.split('.')[1]      
      let userinfo = Base64.decode(paylod)
      let user = JSON.parse(JSON.parse(userinfo).user)
      this.username = user.nickName
    }
  },
  updated:{
  }

}
</script>

<style lang="scss" scoped>
.dashboard {
  &-container {
    margin: 30px;
  }
  &-text {
    font-size: 30px;
    line-height: 46px;
  }
}
</style>
